#!/usr/local/bin/php
<?php
$title = 'nginx: white_list reload';
exec('ps -eo command',$res);
if($res)
{
    foreach ($res as $v)
    {
        if(stripos($v, $title) !==false)
        {
            die('已有运行!'.PHP_EOL);
        }
    }
}
cli_set_process_title($title);
$path = '/www/msg/white_ip_list.conf';
$save_time = 0 ;
do {
    clearstatcache(true,$path);
    $time = filemtime($path);
    if($time>$save_time)
    {
        exec("openresty",$res,$a);
        if($a)
        {
            exec("openresty -s reload",$res,$a);
        }
        $save_time = $time ;
        file_put_contents('./nginx.reload.log', "时间：[".date('Y-m-d H:i:s')."] 重启信息：".join(',',$arr).PHP_EOL,FILE_APPEND);
    }
    sleep(5);
}while(true);